/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package personInfoTests;

import model.Constants;
import model.personInfo.Contacts;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Slayer
 */
public class ContactsTest {
    private Contacts contacts;
    
    private final String PHONE = "12345";
    private final String ADDRESS = "Kyiv, Foo st.";
    private final String SEPARATOR = Constants.LINE_SEPARATOR;
    
    public ContactsTest() {
    }
    
    @Before
    public void setUp() {
        contacts = new Contacts(PHONE, ADDRESS);
    }
    
    @After
    public void tearDown() {
    }
    
    @Test
    public void shouldReturnInitialPhoneWhenGet() {
        //given
        String expected = PHONE;
        //then
        assertEquals(expected, contacts.getPhoneNumber());
    }
    
    @Test
    public void shouldReturnInitialAddressWhenGet() {
        //given
        String expected = ADDRESS;
        //then
        assertEquals(expected, contacts.getAddress());
    }
    
    @Test
    public void shouldChangePhoneWhenSet() {
        //given
        String expected = "54321";
        //when
        contacts.setPhoneNumber(expected);
        //then
        assertEquals(expected, contacts.getPhoneNumber());
    }
    
    @Test
    public void shouldChangeAddressWhenSet() {
        //given
        String expected = "Moskow";
        //when
        contacts.setAddress(expected);
        //then
        assertEquals(expected, contacts.getAddress());
    }
    
    @Test
    public void testToString() {
        //given
        String expected = "Phone number: " + PHONE + SEPARATOR + 
                          "Address: " + ADDRESS + SEPARATOR;
        //then
        assertEquals(expected, contacts.toString());
    }
    
    @Test
    public void testClone() {
        //given
        String expected = contacts.toString();
        //then
        assertEquals(expected, contacts.clone().toString());
    }
    
    @Test
    public void testEquals() {
        //given
        Contacts expected = contacts;
        //then
        assertEquals(expected, contacts.clone());
    }
}
